﻿using ObjectBakery.Adapters;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using ObjectBakery.Adapters.Strategies;
using System.Data;
using System.Collections;
using ObjectBakery.Tests.TestDoubles;
using System.Collections.Generic;

namespace ObjectBakery.Tests
{
    
    
    /// <summary>
    ///This is a test class for AdapterFactoryTest and is intended
    ///to contain all AdapterFactoryTest Unit Tests
    ///</summary>
    [TestClass()]
    public class AdapterFactoryTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for GetAdapter
        ///</summary>
        ///[TestMethod()]
        public void GetDataTableToListAdapterTestHelper()
        {
            var table = new TestFactories.TestTableFactory().BuildAssets();
            var list = new List<Asset>();

            var factory = new AdapterFactory<DataTable, IList>();

            var adapter = factory.GetAdapter<Asset>(table);
            //var adapter = factory.GetAdapter(table, typeof(Asset));

            adapter.Fill(list);

            Assert.IsTrue(list.Count > 0);

        }

        /// <summary>
        ///A test for GetAdapter
        ///</summary>
        ///[TestMethod()]
        public void GetListToDataTableAdapterTestHelper()
        {
            var table = new DataTable();
            var list = new TestFactories.TestAssetFactory().Build();

            var factory = new AdapterFactory<IList, DataTable>();

            var adapter = factory.GetAdapter<Asset>(list);
            //var adapter = factory.GetAdapter(list, typeof(Asset));

            adapter.Fill(table);

            Assert.IsTrue(table.Rows.Count > 0);

        }

      
    }
}
